import { IsString, MinLength, MaxLength, IsOptional, IsEmail, IsNotEmpty, ValidateIf } from 'class-validator';

export class CreateUserDto {
  @IsOptional()
  @IsString({ message: '账号必须是字符串' })
  @MaxLength(11, { message: '账号长度不能超过11位' })
  account?: string;

  @IsOptional()
  @IsEmail()
  email?: string;

  @IsString({ message: '密码必须是字符串' })
  @MinLength(6, { message: '密码长度不能小于6位' })
  password: string;

  @ValidateIf(o => o.account && o.email)
  @IsNotEmpty({ message: '至少需要提供账号或邮箱' })
  identifierCheck?: never;
}
